<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>国内折扣</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/header.css">
    <link rel="stylesheet" href="../css/inlanddiscount.css">
</head>

<body>
    <!-- 头部 -->
    <header>
        <div class="back">
            <a href="./index.html">
                〈
            </a>
        </div>
        <h1>
            国内折扣
        </h1>
        <div class="app">
            <a href="javascript:;">
                <img src="../images/header_app.png" alt="">
            </a>
        </div>
    </header>
    <!-- 搜索 -->
    <section class="search">
        <input type="search" name="" id="sou" placeholder="请输入您想比价的产品">
        <button id="souBtn">搜索</button>
    </section>
    <!-- 主体 -->
    <main>
        <ul class="product">

        </ul>
    </main>
    <!-- 底部 -->
    <footer>
        <ul class="footNav">
            <li>
                <a href="javascript:;">首页</a>
            </li>
            <li>
                <a href="javascript:;">列表</a>
            </li>
            <li>
                <a href="javascript:;">返回</a>
            </li>
        </ul>
        <div class="footCentent">
            <p>
                手机APP下载 万峰智慧商城 -- 掌上比价平台
            </p>
            <p> © www.imuban.cn版权所有</p>
        </div>
    </footer>
</body>

</html>

<script src='https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js'></script>
<script>
    (function() {
        fetch('http://chst.vip:1234/api/getinlanddiscount').then(body => body.json()).then(res => {
            let result = res.result;
            console.log(result);
            let proStr = ''
            result.forEach(item => {
                proStr += `
            <li date-index="${item.productId}">
                <a href="#">
                    <div class="img">
                    ${item.productImg}
                    </div>
                    <div class="centent">
                        <h3>${item.productName}</h3>
                        <div class="price">¥ ${item.productPrice}</div>
                        <span>${item.productFrom} | ${item.productTime}</span>
                    </div>
                </a>
            </li>
            `
            });
            $('.product').html(proStr);
        });
        $('.product').on('click', 'li', function() {
            let curIndex = $(this).attr('date-index');
            console.log(location);
            location.href = './inlanddiscount-2.html?productid=' + curIndex
        })

    })()
</script>